/*
 * MMSeg.h
 *
 *  Created on: 2017年6月21日
 *      Author: heqian
 */

#ifndef MMSEG_MMSEG_H_
#define MMSEG_MMSEG_H_
#include <string.h>
#include <string>
#include <functional>

#include "Word.h"
#include "CharNode.h"
#include "Chunk.h"
#include "Dictionary.h"

using namespace std;

namespace mmseg {

enum CharClass {
	Unknown = 0, Number = 1, Lower = 2, Upper = 4
}
;

typedef function<void(int, int, EnumPos, string)> workCall;

class MMSeg {
public:
	MMSeg(const string& str, Dictionary* dic);
	virtual ~MMSeg();

	void start(workCall call);
	const char* c_str();
private:
	string mStr;
	Dictionary* mDic;

protected:
	UTF_8 getCharClassKey(int cla);
	int getOtherWord(const char** str);
	UTF_8 getChar(const char* str);
	Chunk* seg(char** start, char* end);
	CharNode* maxMatch(CharNode* node, const char* start, const char* end, int* outLen, int *outClass);

	int isSymbol(UTF_8 key);
};

} /* namespace mmseg */

#endif /* MMSEG_MMSEG_H_ */
